#include "GameAppPch.h"

#include "WindowInfo.h"
#include "tinyxml.h"

WindowInfo::WindowInfo()
{
	m_strWindowName = "Dion";
	m_nWidth = DEFAULT_WIDTH;
	m_nHeight = DEFAULT_HEIGHT;
}

WindowInfo::~WindowInfo()
{

}

bool WindowInfo::LoadXML()
{
	char szCurDir[MAX_PATH];
	GetCurrentDirectory(MAX_PATH, szCurDir);
	strcat_s(szCurDir, MAX_PATH, "\\Window.xml");
	TiXmlDocument pDoc(szCurDir);
	if(!pDoc.LoadFile())
		return false;

	TiXmlElement* pRoot = pDoc.FirstChildElement("window");

	if(pRoot)
	{
		TiXmlElement* pNodeWindowName= pRoot->FirstChildElement("name");
		if(pNodeWindowName)
		{
			m_strWindowName = pNodeWindowName->GetText();
		}

		TiXmlElement* pNodeWidth = pRoot->FirstChildElement("width");
		if(pNodeWidth)
		{
			m_nWidth = atoi(pNodeWidth->GetText());
		}

		TiXmlElement* pNodeHeight = pRoot->FirstChildElement("height");
		if(pNodeHeight)
		{
			m_nHeight = atoi(pNodeHeight->GetText());
		}
	}
	else
	{
		return false;
	}

	return true;
}